package com.transpot.controller.sys;

import com.transpot.entry.driver.Driver;
import com.transpot.entry.sys.CountVO;
import com.transpot.service.car.CarService;
import com.transpot.service.customer.CustomerService;
import com.transpot.service.driver.DriverService;
import com.transpot.service.order.OrderService;
import com.transpot.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/sys")
public class CountController {
    @Autowired
    private OrderService orderService;
    @Autowired
    private CustomerService customerService;
    @Autowired
    private CarService carService;
    @Autowired
    private DriverService driverService;

    /**
     * 获取首页显示的全部计数
     * @return
     */
    @GetMapping("/getCount")
    public R getCount() {
        long count = orderService.count();
        long count1 = customerService.count();
        long count2 = carService.count();
        long count3 = driverService.count();
        CountVO countVO = new CountVO();
        countVO.setCarNumber((int) count2);
        countVO.setCustomerNumber((int) count1);
        countVO.setDriverNumber((int) count3);
        countVO.setOrderNumber((int) count);
        return R.success(countVO);
    }
}
